<?php


namespace App\Http\Controllers\Web;


use App\Events\ProductStatusChanged;
use App\Facade\Flow;
use App\Http\Controllers\Controller;
use http\Client\Request;
use Illuminate\Contracts\Database\ModelIdentifier;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use function foo\func;

class FuwuController extends Controller
{
    public function index()
    {
        echo Flow::currentNode();
        $res = DB::getDefaultConnection();
        echo $res;
        echo App::basePath();
    }

    public function useResolve()
    {
        $api = resolve('DB');
        print_r($api);
    }

    public function rongqi()
    {
        echo "就是传入一个接口和一个实现类，来实现解耦";
        echo "bind(interface,class)"."<br>";

        \app()->bind('haha', function (){
            return new apple();
        });
        $class = resolve('haha');
        print_r($class);
//        \app()->make('food');
    }

    public function useContract(Application $app)
    {
        $vv = $app->basePath();
        echo $vv;
//        $xx = $db->connection;
//        echo $xx;
    }

    public function useEvent()
    {
//        Event::push('ProductStatusChanged', ['xxx']);
//        \event(ProductStatusChanged('vvv'));
        \event(new ProductStatusChanged('事件存储过来的数据'));
    }



}
interface food
{
    function weight();
}
class apple implements food
{
    public function weight()
    {
        echo "苹果的重量用斤";
    }
}
